int red=10;
int yellow=9;
int D=11;
int valD=0;
char check;



void setup(){
  Serial.begin(9600);
  
  pinMode(D,INPUT);
  pinMode(red,OUTPUT);
  pinMode(yellow,OUTPUT);
}

void loop(){
  valD=digitalRead(D);
  if (Serial.available() > 0) {
    check =Serial.read();
    Serial.println(check);
  }
  
  switch(check){
    case 'L':
      if(valD ==HIGH){
        //Serial.println("LOCK");
        digitalWrite(yellow,HIGH);
        digitalWrite(red,HIGH);
        delay(1000);
        digitalWrite(red,LOW);}
       else{
        digitalWrite(yellow,LOW);
        digitalWrite(red,LOW);
       }
      break;
    case 'U':
      if(valD == LOW){
        //Serial.println("UNLOCK");
        digitalWrite(9,LOW);
        digitalWrite(10,HIGH);
        delay(1000);
        digitalWrite(10,LOW);
        delay(1000);
    }
      else{
        digitalWrite(9,LOW);
        digitalWrite(10,LOW);
      }
  }
}
